<?php
require_once '../../include/common.inc.php';
require_once '../function.php';
if(stripos(auth_group($_SESSION['login_gid']),'sys_log')===false)exit("没有权限！");
switch($act){
	case "msg_audit":

        $get_data['rid'] = $def_cfg;
        $get_data['ChatId'] = $uid;
        $get_data['ToChatId'] = 'ALL';
        $get_data['msg'] = $_REQUEST['msg'];
        $time_res = curl_get($get_data, 'sendMsgByid', $liveapi_url);
        msg_audit(implode(',',$id));
		break;

    case "log_del":
        log_del(implode(',',$id));
        break;
	case "clear_log":
		clear_log(implode(',',$id));
		break;
	case "export":
		include '../../include/PHPExcel/PHPExcel.php';
		include '../../include/PHPExcel/PHPExcel/Writer/Excel2007.php';
		//或者include 'PHPExcel/Writer/Excel5.php'; 用于输出.xls的
		//创建一个excel
		$objPHPExcel = new PHPExcel();
		//保存excel—2007格式
		$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
		//print_r($objWriter);exit;
		//或者$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel); 非2007格式
		echo $objWriter->save("xxx.xls");
		echo 'ok';
		//设置excel的属性：
		//创建人
		$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
		//最后修改人
		$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
		//标题
		$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
		//题目
		$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
		//描述
		$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
		//关键字
		$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
		//种类
		$objPHPExcel->getProperties()->setCategory("Test result file");
		//设置当前的sheet
		$objPHPExcel->setActiveSheetIndex(0);
		//设置sheet的name
		$objPHPExcel->getActiveSheet()->setTitle('Simple');
		//设置单元格的值
		$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String');
		$objPHPExcel->getActiveSheet()->setCellValue('A2', 12);
		$objPHPExcel->getActiveSheet()->setCellValue('A3', true);
		$objPHPExcel->getActiveSheet()->setCellValue('C5', '=SUM(C2:C4)');
		$objPHPExcel->getActiveSheet()->setCellValue('B8', '=MIN(B2:C5)');
		echo 'ok';
		break;
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../assets/css/dpl-min.css" rel="stylesheet" type="text/css" />
<link href="../assets/css/bui-min.css" rel="stylesheet" type="text/css" />
<link href="../assets/css/page-min.css" rel="stylesheet" type="text/css" />
<!-- 下面的样式，仅是为了显示代码，而不应该在项目中使用-->
<link href="../assets/css/prettify.css" rel="stylesheet" type="text/css" />
<style type="text/css">
code { padding: 0px 4px; color: #d14; background-color: #f7f7f9; border: 1px solid #e1e1e8; }
</style>
<script>
Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
function ftime(time){
	return new Date(time*1000).Format("yyyy-MM-dd hh:mm:ss");
}


var type=[];
type["0"]="聊天";
type["1"]="登陆";
type["2"]="注册";
type["3"]="入室";
</script>
</head>
<body>
<div class="container"  style=" min-width:1000px;">
<form  class="form-horizontal" action="" method="get"> 
  <ul class="breadcrumb">
    <li class="active">
    关键字：
      <input type="text" name="key" id="key"class="abc input-default" placeholder=""> 
      &nbsp;&nbsp;
      <button type="submit"  class="button ">查询</button>
<!--      <button type="button"  class="button  button-danger" id="add_ban_bt" onClick="if(confirm('确定审核通过所选？')){$('#act').val('msg_audit');$('#log_list').submit()}">审核所选</button>-->

        <button type="button"  class="button  button-danger" id="add_ban_bt" onClick="if(confirm('确定删除？')){$('#act').val('log_del');$('#log_list').submit()}">删除所选</button>

        <!--	  <button type="button"  class="button  button-danger" id="add_ban_bt" onClick="if(confirm('确定清空日志？'))location.href='?act=clear_log'">清空日志</button>-->
<!--	  <button type="button"  class="button  button-danger" id="add_ban_bt" onClick="location.href='?act=export'">导出</button>-->
    &nbsp;&nbsp;</li>
   
  </ul>
  </form>
  <form action="" method="POST" enctype="application/x-www-form-urlencoded"  class="form-horizontal" id="log_list"><input id="act" type="hidden" name="act" value="msg_audit">
  <table  class="table table-bordered table-hover definewidth m10">
    <thead>
      <tr style="font-weight:bold" >
        <td width="30" align="center" bgcolor="#FFFFFF">编号</td>
        <td width="19" align="center" bgcolor="#FFFFFF"><input type="checkbox" onClick="$('.ids').attr('checked',this.checked); "></td>
        <td width="74" align="center" bgcolor="#FFFFFF">msgid</td>
        <td width="74" align="center" bgcolor="#FFFFFF">UID</td>
        <td width="100" align="center" bgcolor="#FFFFFF">昵称</td>
        <td width="100" align="center" bgcolor="#FFFFFF">IP</td>
        <td width="120" align="center" bgcolor="#FFFFFF">时间</td>
<!--        <td width="36" align="center" bgcolor="#FFFFFF">类型</td>-->
        <td align="center" bgcolor="#FFFFFF">描述</td>
        <td width="120" align="center" bgcolor="#FFFFFF">操作</td>
      </tr>
    </thead>
    
<?php
echo audit_list(20,$key,'
    <tr>
      <td align="center" bgcolor="#FFFFFF">{id}</td>
      <td align="center" bgcolor="#FFFFFF"><input type="checkbox" class="ids" name="id[]" value="{id}"></td>
      <td align="center" bgcolor="#FFFFFF">{msgid}</td>
      <td align="center" bgcolor="#FFFFFF">{uid}</td>
      <td align="center" bgcolor="#FFFFFF">{uname}</td>
      <td align="center" bgcolor="#FFFFFF">{ip}&nbsp;</td>
      <td align="center" bgcolor="#FFFFFF"><script>document.write(ftime({mtime})); </script></td>
      <td align="center" class="content-msg" bgcolor="#FFFFFF">{msg}</td>
      <td align="center" bgcolor="#FFFFFF">
      <button type="button" class="button button-mini button-danger" onclick="location.href=\'?act=msg_audit&id[]={id}&uid={uid}&msg={msg}\'" ><i class="x-icon x-icon-small icon-ok icon-white"></i>审核</button>
      <button type="button" class="button button-mini button-danger" onclick="if(confirm(\'确定删除？\'))location.href=\'?act=log_del&id[]={id}\'" ><i class="x-icon x-icon-small icon-trash icon-white"></i>删除</button></td>

    </tr>
')?>


  </table>
  </form> 
    <ul class="breadcrumb">
    <li class="active"><?=$pagenav?>
    </li>
  </ul>
</div>
<script type="text/javascript" src="../assets/js/jquery-1.8.1.min.js"></script> 
<script type="text/javascript" src="../assets/js/bui.js"></script> 
<script type="text/javascript" src="../assets/js/config.js"></script>
<script>
$('.content-msg').each(function (i,v) {
    $(this).html($(this).text());
});
</script>
</body>
</html>
